package dto

import (
	"time"

	"git.bybit.com/svc/stub/pkg/pb/api/consts/euser"
	"git.bybit.com/svc/stub/pkg/pb/enums/ekycadmin"
	"git.bybit.com/svc/stub/pkg/pb/enums/kyc"
)

type GetIdempotentCondition struct {
	MemberID         int64
	SiteID           euser.BrokerID
	Channel          kyc.KYCProvider
	ProviderCreateAt int64
	Action           ekycadmin.KYCAdminAction
	Level            int8
	RecordID         string
	SerialType       int8
}

type ActionStateRecord struct {
	MemberID             int64     // UID
	SiteID               int16     // 申请KYC站点(0:主站,1:韩国站,2:土耳其站)
	ExternalUID          string    // 外部 UID
	RecordID             string    // 记录id(sumsub: applicant_id, jumio: workflow_execution_id, scanReference)
	AccountID            string    // 账号id(sumsub:applicant_id, jumio: account_id)
	VerifyContent        string    // 认证内容，数组，以‘,’分隔
	Level                int8      // KYC等级(0-3)
	Channel              int8      // channel 认证通道(1:sumsub,2:jumio)
	Action               int8      // actionsvc 动作状态(0:ticket, 1:init, 2:pending, 3:complete, 4:reset)
	Decision             int8      // decision 最终认证结果(0:unknown,1:success,2:reject)
	ProviderDecision     int8      // provider_decision 服务商认证结果(0:unknown, 1:success, 2:reject)
	RejectReason         string    // reject_reason 最终拒绝原因
	ProviderRejectReason string    // provider_reject_reason 服务商拒绝原因
	DocType              int8      // doc_type 证件大类
	DocSubtype           int8      // doc_subtype 证件子类
	DocNumber            string    // doc_number 证件号(密文)
	Country              string    // country 证件签发国(KYC国籍)
	Nationality          string    // nationality 原籍
	AddressCountry       string    // address_country 居住国
	FirstName            string    // first_name 名字(密文)
	LastName             string    // last_name 姓氏(密文)
	Dob                  string    // dob 出生日期(密文)
	IdempotentID         string    // idempotent_id 幂等id
	ReviewTime           int64     // review_time 验证时间(时间戳 ms)
	ProviderCreateAt     int64     // provider_create_at 供应商回调时间(时间戳 ms)
	DocDetail            string    // doc_detail 证件详情，JSON(密文)
	IssuingDate          time.Time // issuing_date 签发日期
	ExpireDate           time.Time // expire_date 有效期
	FaceDetail           string    // face_detail 人脸详情，JSON(密文)
	AddressDetail        string    // address_detail 地址详情，JSON(密文)
	ClientDetail         string    // client_detail 客户端详情，JSON
	SerialType           int8      // serial_type 证件序列类型(0:第一证件;1:第二证件)
}

type ActionStateLogRecord struct {
	IdempotentID   string // idempotent_id 幂等id(kyc_action_state.idempotent_id)
	MemberID       int64  // member_id UID
	SiteID         int16  // site_id 申请KYC站点(0:主站,1:韩国站,2:土耳其站)
	RecordID       string // record_id 记录id(sumsub: applicant_id, jumio: workflow_execution_id, scanReference)
	AccountID      string // account_id 账号id(sumsub:applicant_id, jumio: account_id)
	Channel        int8   // channel 认证通道(1:sumsub 2:jumio)
	Level          int8   // level KYC等级(0-3)
	VerifyContent  string // verify_content 认证内容，数组，以‘,’分隔，[x, x, x, ...]
	Action         int8   // actionsvc 动作状态(0:ticket, 1:init, 2:pending, 3:complete, 4:reset)
	EventAt        int64  // event_at 供应商事件发生时间戳(ms)
	EventData      string // event_data 扩展字段
	ReservedField1 string // reserved_field1 保留字段1
	ReservedField2 int64  // reserved_field2 保留字段2
}

type ActionStateClientDetail struct {
	ClientIP string `json:"client_ip"` // 通道返回的客户端IP
	From     string `json:"from"`      // 中台自己记录的设备细分（Android、iOS、Web）
	Source   string `json:"source"`    // 通道返回的客户端的源
}

type ActionStateAddressDetail struct {
	Country     string `json:"country"`
	State       string `json:"state"`
	City        string `json:"city"`
	FullAddress string `json:"full_address"`
	PostalCode  string `json:"postal_code"`
}

type ActionStateDocDetail struct {
	DocFront       string `json:"doc_front"`
	DocBack        string `json:"doc_back"`
	PersonalNumber string `json:"personal_number"`
}

type ActionStateFaceDetail struct {
	FaceImage         string `json:"face_image"`
	LivenessImage     string `json:"liveness_image"`
	SimilarityChecked string `json:"similarity_checked"`
	ValidityChecked   string `json:"validity_checked"`
}
